import https from '@/plugins/luch-request_0.0.7/request'

export const getBasicUserApi = data => {
	return https.get('/apihkds/api/user/basicProfile', { t: Date.now(), ...data }, {}, { hideError: true })
}

export const getUserApi = () => {
	return https.get('/apihkds/api/user/profile', { t: Date.now() }, {}, { hideError: true })
}

// 编辑资料
export const editUserApi = (data) => {
	return https.post('/apihkds/api/user/editProfile', data)
}

export const checkLogin = () => {
	return https.get('/apihkds/api/user/checkLogin')
}

// 微信授权回调
export const oauthCallback = (url, data) => {
	return https.get('/apihkds/api/oauth/callback' + url, data)
}

export const getImgProxyUrl = () => {
	const url = (process.env.NODE_ENV === 'development') ? '/api/apihkds/api/proxy/img?url=' : '/apihkds/api/proxy/img?url='
	return url
}

// 客服接口
export const getChat = (data) => {
	return https.get('/api/v4/chat', data)
}

// 分享海报相关接口
// type == 1 为用户获客，type == 2 为案例， type == 3 为攻略， type == 4 为工艺， type == 5 为名片， type == 6 为邀请开店， type == 7 为活动
// type == 7 为一键获客攻略分享, type == 9 为一键获客案例分享, type == 10 为一键获客海报分享, type == 11 为一键获客工艺分享
export const getShareImgCom = (type, data) => {
	if (type === 1) {
		return https.post('/apihkds/api/user/getposter', data)
	} else if (type === 2) {
		return https.post('/apihkds/api/case/get_public_poster', data)
	} else if (type === 3) {
		return https.post('/apihkds/api/zxgl/get_public_poster', data)
	} else if (type === 4) {
		return https.post('/apihkds/api/technology/get_public_poster', data)
	} else if (type === 5) {
		return https.post('/apihkds/api/user/visitingcard', data)
	} else if (type === 6) {
		return https.post('/apihkds/api/user/invite', data)
	} else if (type === 7) {
		return https.post('/apihkds/api/promotion/getposter', data)
	} else if (type === 8) {
		return https.post('/apihkds/api/material/poster', data)
	} else if (type === 10) {
		return https.post('/apihkds/api/poster/get_poster', data)
	}
}

// 获取用户认证信息
export const getRoleRealApi = data => {
	return https.get('/apihkds/api/user/role/real/edit', data, {}, { hideError: true })
}

// 公共定位接口
export const getUserRegion = data => {
	return https.get('/apihkds/api/misc/getUserRegion', { t: Date.now(), ...data }, {}, { hideError: true })
}
